<?php
namespace app\api\logic;
use think\Cache;
use think\Request;
/**
 * Class 环信token.
 * User: rowan
 * Date: 2017/11/1 17:07
 */

class Gethxtoken extends \app\api\BaseModel
{
	function __construct($data = array()){
		parent::__construct($data); 
	}


	//环信token
	public function hxToken(){     
      	//环信接入
	    $easemob = new \app\api\service\Easemob();
	    $result = $easemob->getToken();
		$array_hxtoken['hxtoken'] = $result;
	    return $array_hxtoken;
	}

	//注册环信
	public function hxcreateUser()
	{
		$uid = $this->user['id'];
		$data = db('member')->where('id='.$uid)->find();
		$username = '10_'.time();
		$password = '123456';
		$nickname = $data['nickname'];
		$easemob = new \app\api\service\Easemob();
		$result = $easemob->createUser($username,$password,$nickname);
//		if(isset($result['entities']))return  $result;
//		return ['message'=>'环信资源有限'];
		return $result;
	}



}